#ifndef __AS_WAITING__H__
#define __AS_WAITING__H__

#include "ASControl.h"
#include "ASImage.h"

typedef enum
{
    AS_WAITING_TYPE_DEFAULT,//default type,just draw with vm api
    AS_WAITING_TYPE_LINE,//display as a line
    AS_WAITING_TYPE_TEXT,
    AS_WAITING_TYPE_IMG,//img type

    AS_WAITING_TYPE_MAX
} as_waiting_type;


typedef struct
{
    /* base */
    as_control base;

    /* attributes */
    ASINT timer_id;
    as_timer_cb timer_cb;
    as_waiting_type type;
    ASINT update_period;//unit : ms
    ASUINT bg_color;
    as_image* bg_img;
    ASINT bg_hidden;
    as_rect valid_area;

    ASINT start_idx;//internal

    /* methods */

    /*
     *	[description] change the update period of waiting control
     *  [param] ctrl_p : which you want to change property
     *  [param] period : take millisecond as unit,should not less than 50ms
     *  [return] as_ret : AS_OK ,or error code
     */
    as_ret (*change_period)(as_control* ctrl_p, ASINT period);

    /*
     *	[description] change the display type of waiting control
     *  [param] ctrl_p : which you want to change property
     *  [param] type : enum as_waiting_type
     *  [return] as_ret : AS_OK ,or error code
     */
    //as_ret (*change_type)(as_control* ctrl_p, as_waiting_type type);

    /*
     *	[description] change the background color of waiting control
     *  [param] ctrl_p : which you want to change property
     *  [param] bg_color : background color (0xrrggbb)
     *  [return] as_ret : AS_OK ,or error code
     */
    as_ret (*change_bg_color)(as_control* ctrl_p, ASUINT bg_color);

    as_ret (*set_bg_hidden)(as_control* ctrl_p, ASINT if_hidden);

    as_ret (*set_valid_area)(as_control* ctrl_p, as_rect valid_area);
} as_waiting;


/*
 *	[description] create a waiting control
 *  [param] paint_buf : which buffer do you want to paint
 *  [param] area : area of this control
 *  [param] type : display type of waiting
 *  [return] as_waiting* : if NULL , means create failed.
 *                       else return the pointer of waiting.
 */
as_waiting* as_ctrl_waiting_create(as_rect area, as_waiting_type type);

/*
 *	[description] destroy an existed waiting
 *  [param] ctrl_waiting_p : pointer of waiting control
 *  [return] as_ret : AS_OK means destroy successful,otherwise are abnormal.
 */
as_ret as_ctrl_waiting_destroy(as_waiting* ctrl_waiting_p);


#endif//__AS_WAITING__H__